package com.example.a2209_shop

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.view.get
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.a2209_shop.databinding.ActivityMainBinding
import com.example.base.entity.UserEntity
import com.example.base.mvvm.BaseViewActivity

@Route(path = "/app/MainActivity")
class MainActivity : BaseViewActivity<ActivityMainBinding>() {
    @Autowired
    @JvmField
    var fragId = 0

    override fun initData() {
    }

    override fun initView() {
        ARouter.getInstance().inject(this)
        //找到导航栏宿主
        val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment

        val navController = navHostFragment.navController

        binding.bottom.setupWithNavController(navController)
        //
       //binding.bottom.menu.get(fragId).isChecked = true

        when(fragId){
            0->{ binding.bottom.selectedItemId = R.id.homeFragment}
            1->{binding.bottom.selectedItemId = R.id.cateFragment}
            2->{binding.bottom.selectedItemId = R.id.carFragment}
            3->{binding.bottom.selectedItemId = R.id.mineFragment}
        }


    }

    override fun getLayout(): Int  = R.layout.activity_main

}